import Http from 'utils/request'
// 公共服务相关接口
const context = process.env.VUE_APP_CONSOLE_PATH

/**
 * mock模拟数据 示例
 * @param {*} params params数据对象
 * @param {Object} mockFile 接口名称对应的mock数据文件
 */
export const mockList = params =>
  Http.fetch(`${context}/mockList`, params, {
    mockFile: `list${params.type}`
  })

/* ==================    中台 服务接口      ==================== */

/**
 * 上传图片接口，支持多文件上传
 * @param {Array} params file
 */
export const uploadFile = params =>
  Http.fetch(`${context}/upload`, params, {
    contentType: 'upload'
  })

/* ==================    common 服务接口      ==================== */
/**
 * 登录
 * @param {*} params
 */
export const login = params => Http.fetch(`${context}/auth/login`, params, { hasErrMsg: true })

/**
 *  登出
 * @param {*} params
 */
export const logout = params =>
  Http.fetch(`${context}/auth/logout`, params, {
    hasErrMsg: true
  })

/**
 * 获取用户信息
 * @param {*} token
 */
export const getUserInfo = params =>
  Http.fetch(`${context}/auth/info`, params, {
    method: 'get',
    hasErrMsg: true
  })

/**
 * 字典查询
 * @param {*} params
 */
export const queryDictByCodes = params =>
  Http.fetch(`${context}/system/sysDic`, params, {
    method: 'post'
  })

/**
 * 查询所有企业
 * @param {*} params
 */
export const queryAllCompany = params =>
  Http.fetch(`${context}/company/list`, params, {
    method: 'post'
  })

/**
 * 查询所有区域
 * @param {*} params
 */
export const queryAllCity = params =>
  Http.fetch(`${context}/system/queryAllCity`, params, {
    method: 'post'
  })
